package com.lej.app_main.helper

import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.lej.core.common.LogTags
import com.lej.core.utils.extention.logI
import com.lej.dataservice.club.http.baseApiService
import com.lej.dataservice.club.http.checkData
import kotlinx.coroutines.launch

object ADHelper {
    fun getAdInfo(activity: AppCompatActivity) {
        activity.lifecycleScope.launch {
            val info = kotlin.runCatching {
                val info = baseApiService.floatad().checkData()
                if (info.show_mode == 0) null else info
            }.onFailure {
                "获取弹窗信息失败".logI(LogTags.upgrade)
                it.message?.logI(LogTags.upgrade)
            }.getOrNull() ?: return@launch
        }
    }
}
